home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 60750 / 60750.xpi / surfcanyon_sc.xpi / content / sc_shareaholic.js < prev    next >
Text File  |  2009-11-12  |  3KB  |  61 lines

  1. //*************************************/
  2. //    Shareaholic Library
  3. //    Copyright (C) Shareaholic.com
  4. //*************************************/
  5.  
  6. var surfcanyon_SHR_library = {
  7.     apiurl: 'http://www.shareaholic.com/api/share/',
  8.     apikey: 'e4bd47a7ac22eb93aadbd5ea8dc6d77d',
  9.     source: 'www.SurfCanyon.com',
  10.     v: 1,
  11.         
  12.     destination: function(service_id, apitype, shorten_url){
  13.         if (!shorten_url){
  14.             var shr_url = this.apiurl+"?v="+this.v+"&apitype="+apitype+"&apikey="+this.apikey+"&service="+service_id+"&title="+encodeURIComponent(escape(content.document.title))+"&link="+encodeURIComponent(escape(content.location.href))+"¬es="+encodeURIComponent(escape(content.getSelection()))+"&source="+this.source;
  15.         } else {
  16.             var shr_url = this.apiurl+"?v="+this.v+"&apitype="+apitype+"&apikey="+this.apikey+"&service="+service_id+"&title="+encodeURIComponent(escape(content.document.title))+"&link="+surfcanyon_short_url+"¬es="+encodeURIComponent(escape(content.getSelection()))+"&source="+this.source;
  17.         }
  18.         this.opennewtab(shr_url);
  19.     },
  20.     dest_mailto: function() {
  21.         this.census(201);
  22.         window.top.getBrowser().loadURI("javascript:crlf=%22%250D%250A%22;h=location.href;t=document.title;e%20=%20%22%22%20+%20(window.getSelection%20?%20window.getSelection()%20:%20document.getSelection%20?%20document.getSelection()%20:%20document.selection.createRange().text);%20if%20(e!=null)%20location=%22mailto:%22%20+%20%22?Subject=%22%20+%20escape(t)%20+%20%22&Body=%22%20+%20escape(e).replace(/%20/g,%20%22+%22)%20+%20crlf%20+%20escape(h)%20+' (sent via http://www.SurfCanyon.com)'+%20%22%20%22;%20void%200");
  23.     },    
  24.     census: function(service_id, notes) {
  25.         var sc_record_http_request = new XMLHttpRequest();
  26.         var sc_shareaholic_url = "http://www.shareaholic.com/api/share/?v=1&apitype=2&apikey="+this.apikey+"&service="+service_id+"&title="+escape(content.document.title)+"&link="+escape(content.location.href)+"¬es="+escape(content.getSelection());
  27.         sc_record_http_request.open('GET', sc_shareaholic_url, true);
  28.         sc_record_http_request.send(null);
  29.     },
  30.     opennewtab: function(webpage) {
  31.         var createtab = gBrowser.addTab(webpage);
  32.         gBrowser.selectedTab = createtab;
  33.     },
  34.     makeshort: function() {
  35.         surfcanyon_short_url = content.location.href;
  36.         var request_url='http://api.j.mp/shorten?version=2.0.1&login=shareaholic&apiKey=R_83932e4c5d02d1f94aea0f40fbc557ec&longUrl='+surfcanyon_short_url;
  37.         var jmp_http_request = new XMLHttpRequest();
  38.         jmp_http_request.open('GET', request_url, true);
  39.         jmp_http_request.onreadystatechange = function() {
  40.             if (jmp_http_request.readyState == 4) {
  41.                 if (jmp_http_request.status == 200) {
  42.                     var jmp_json_object = YBJSON.parse(jmp_http_request.responseText);
  43.                     if (jmp_json_object.statusCode == "OK") {
  44.                         var first_result;
  45.                         for (var r in jmp_json_object.results){
  46.                             first_result = jmp_json_object.results[r];
  47.                             break;
  48.                          }
  49.                         surfcanyon_short_url = first_result.shortUrl;
  50.                     } else {
  51.                         surfcanyon_short_url = content.location.href;
  52.                     }
  53.                 }
  54.             }
  55.             return surfcanyon_short_url;
  56.         };
  57.         jmp_http_request.send(null);
  58.     }    
  59. };
  60.  
  61.